
package com.bash.carrep.ui.datasource;

import com.bash.carrep.dao.enties.Login;
import com.bash.carrep.dao.general.CRUD;
import com.vaadin.data.util.BeanItemContainer;
import java.io.Serializable;
import java.util.List;

/**
 *
 * @author p.bashizi
 */
public class UserContainer extends BeanItemContainer<Login> implements Serializable {

    public UserContainer() throws IllegalArgumentException {
        super(Login.class);
        
        
    }
    public static final Object[] NATURAL_COL_ORDER = new Object[]{"username", "password", "creditLevel", "actif"};
    public static final String[] COL_HEADERS_ENGLISH = new String[]{"Nom d'utilisateur", "Mot de passe", "Credit", "Actif"};
    static CRUD crud = CRUD.getInstance();
    
    public static UserContainer getData() {

       UserContainer c = null;
       
       try {
 
         
            crud.start();
            c = new UserContainer();
            List<Login> list = crud.getAll(Login.class);
            c.addAll(list);

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            crud.stop();
        }

        return c;
    }
}
